#测试角色管理页面
from time import sleep
from common.Untils import WJDriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
class WJRole:
    url = ""
    driver = ""

    def __init__(self):
        #WJLogin.WJLogin().LoginSuccess()
        self.url = "http://8.155.1.153:8081/system/role"
        self.driver = WJDriver.driver
        self.driver.get(self.url)
        WJDriver.Login()
        #sleep(2)
        #点击系统管理
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/div/span/div").click()
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/ul/li[2]").click()

    def TestByRoleFunction(self):
        # self.driver.find_element(By.XPATH,"").send_keys()
        # self.driver.find_element(By.XPATH,"").click()
        sleep(1)
        #1.输入框中输入要搜索的角色名称，点击查询################################
            #输入框输入名字
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("admin")
            #点击查询
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button").click()
        print("角色管理页面:1正常")
        #2.点击重置#########################################################
            #点击重置
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]/button").click()
        print("角色管理页面:2正常")
        #3.点击状态两下######################################################
            #点击两下
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[3]/td[4]/button").click()
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[3]/td[4]/button").click()
        print("角色管理页面:3正常")
        #4.点击新建，全部正常填写##############################################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
        #sleep(1)
            #填写角色名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("自动化"+WJDriver.name)
            #填写编码
        self.driver.find_element(By.CSS_SELECTOR, "#code").send_keys(WJDriver.name)
            #选择状态
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[3]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[3]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]/div").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        print("角色管理页面:4正常")
        #5.点击新建，全部不填写###############################################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
        #sleep(1)
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("角色管理页面:5正常")
        #6.点击新建，填写角色名称，不填写角色编码，不填写状态######################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
        #sleep(1)
            #填写角色名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("自动化"+WJDriver.name)
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("角色管理页面:6正常")
        #7.点击新建，填写角色名称，填写角色编码，不填写状态########################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
        #sleep(1)
            #填写角色名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("自动化"+WJDriver.name)
            #填写角色编码
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys(WJDriver.name)
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("角色管理页面:7正常")
        #8.点击新建，不填写角色名称，不填写角色编码，填写状态#######################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #填写状态
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[3]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[3]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("角色管理页面:8正常")
        #9.点击新建，填写角色名称，不填写角色编码，填写状态#########################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #填写角色名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("自动化"+WJDriver.name)
            #填写状态
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[3]/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[3]/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("角色管理页面:9正常")
        #10.点击新建，不填写角色名称，填写角色编码，不填写状态######################
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #填写角色编码
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys(WJDriver.name)
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("角色管理页面:10正常")
        #11.点击编辑#########################################################
            #点击编辑
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[6]/div/div[1]").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        print("角色管理页面:11正常")

#         self.driver.quit()
# role=WJRole()
# role.TestByRoleFunction()

